package com.sdap2.common.service.impl;

import com.sdap2.common.dao.LogicDAO;
import com.sdap2.common.entity.LogicEntity;
import com.sdap2.common.service.LogicService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

public abstract class BaseService<T extends LogicEntity> implements LogicService<T> {
    
    protected abstract LogicDAO<T, Long> getRepository();
    
    @Override
    public T save(T entity) {
        return getRepository().save(entity);
    }
    
    @Override
    public T findById(Long id) {
        return getRepository().findById(id).orElse(null);
    }
    
    @Override
    public Page<T> findAll(Pageable pageable) {
        return getRepository().findAll(pageable);
    }
    
    @Override
    public void deleteById(Long id) {
        getRepository().deleteById(id);
    }
} 